home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.02 Feb 90 / Jorg Code / ListDoc.cp < prev    next >
Encoding:
Text File  |  1989-12-19  |  1.4 KB  |  74 lines  |  [TEXT/MPS ]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Events.h>
  5. #include <Controls.h>
  6. #include <Windows.h>
  7. #include <Menus.h>
  8. #include <TextEdit.h>
  9. #include <Dialogs.h>
  10. #include <Desk.h>
  11. #include <Scrap.h>
  12. #include <ToolUtils.h>
  13. #include <Memory.h>
  14. #include <SegLoad.h>
  15. #include <Files.h>
  16. #include <OSUtils.h>
  17. #include <Traps.h>
  18. #include <StdLib.h>
  19.  
  20. #include "TDocument.h"
  21. #include "DisplList.h"
  22. #include "ListDoc.h"
  23.  
  24. // create and delete the document window
  25.  
  26. TListDoc::TListDoc(short resID)    : (resID)
  27. {
  28.     Rect brect;
  29.     fItem1Set = fItem2Set = fItem3Set = false;
  30.     SetRect(&brect,10,100,70,140);
  31.     obj1 = new TRoundRect(brect);
  32.     SetRect(&brect,90,100,150,140);
  33.     obj2 = new TOval(brect);
  34.     SetRect(&brect,170,100,230,140);
  35.     obj3 = new TRect(brect);
  36.     fObjList = new TObjList();
  37.     ShowWindow(fDocWindow);    
  38. }
  39.  
  40. TListDoc::~TListDoc(void)
  41. {
  42.     delete fObjList;
  43.     HideWindow(fDocWindow);
  44. }
  45.  
  46. void TListDoc::DoUpdate(void)
  47. {
  48.     BeginUpdate(fDocWindow);                // this sets up the visRgn 
  49.     if ( ! EmptyRgn(fDocWindow->visRgn) )    // draw if updating needs to be done 
  50.       {
  51.         DrawWindow();
  52.       }
  53.     EndUpdate(fDocWindow);
  54. }
  55.  
  56. // Draw all objects contained in the list. 
  57.  
  58. void TListDoc::DrawWindow(void)
  59. {
  60.     TObjLink* temp;
  61.     
  62.     SetPort(fDocWindow);
  63.     EraseRect(&fDocWindow->portRect);
  64.     
  65.     if (fObjList->NumObjs() != 0)
  66.         for (temp = fObjList->Header(); 
  67.             temp != nil; temp = temp->GetNext())
  68.         {
  69.             SysBeep(1);
  70.             temp->GetmyObj()->Draw(qd.gray);
  71.         }
  72. } // DrawWindow
  73.  
  74.